import pandas as pd

# 定义文件路径
item_inter_num_path = '/data/GuoCu_data/processed_data/feature/item/item_inter_num.csv'
user_item_inter_rank_path = '/data/GuoCu_data/processed_data/feature/item/user_item_inter_rank.csv'
output_path = '/data/GuoCu_data/processed_data/feature/item/item_features.csv'

# 读取文件
try:
    df_item_inter_num = pd.read_csv(item_inter_num_path)
    df_user_item_inter_rank = pd.read_csv(user_item_inter_rank_path)
except FileNotFoundError as e:
    print(f"文件读取错误: {e}")
else:
    # 根据content_id列进行合并
    merged_df = pd.merge(df_user_item_inter_rank, df_item_inter_num,on='content_id', how='outer')

    # 将合并后的数据保存为item_features.csv
    merged_df.to_csv(output_path, index=False)
